using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class LevelSelectManager : MonoBehaviour
{
    public static LevelSelectManager Instance { get; private set; }
    
    [SerializeField] private GameSO gameSO;
    [SerializeField] private MapLevelUI mapLevelUI;

    private void Awake()
    {
        Instance = this;
    }

    private void Start()
    {
        mapLevelUI.ShowMapList(gameSO.mapArray);//这边将数据和UI进行了分离后的连接
    }

    public void SetSelectedMap(int mapID)
    {
        gameSO.selectedMapID = mapID;
    }

    public int[] GetSelectMap()
    {
        return gameSO.mapArray[gameSO.selectedMapID - 1].numberOfLevel;
    }

    public void SetSelectLevel(int levelID)
    {
        gameSO.selectedLevelID = levelID;
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    }
}
